﻿@using CoreData
@using Helper
@using System.Text.RegularExpressions
@model List<ShoppingCart>
@{
    ViewBag.Title = "Thanh Toán";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@{
    var toTalProduct = 0;
    var toTalPrice = 0;
    if (Model != null)
    {
        foreach (var item in Model)
        {
            toTalProduct = toTalProduct + item.Amount;
        }
        foreach (var item in Model)
        {
            toTalPrice = toTalPrice + item.TotalItemPrice;
        }
    }
}
@section HeadResource{
    <title>@ViewBag.Title</title>
    <link href="@Url.Content("~/Content/css/payment.css")" rel="stylesheet" type="text/css" />
}
@section BottomResource{
    <script src="@Url.Content("~/Content/js/payment.js")" type="text/javascript"></script>
}
@{
    var cart = (List<ShoppingCart>)Session["ShoppingCart"];
    List<ShoppingCart> lstCart = cart;
}
<div class="cart-grid grid-view">
    <div class="breadcrumbs">
        <ul>
            <li><a href="#">Trang chủ</a> <span class="crumb">/</span> </li>
            <li><a href="#">Giỏ hàng</a> <span class="crumb">/</span> </li>
            <li><span>Thanh toán</span> </li>
        </ul>
    </div>
    <div class="product-title">
        <h1>
            Thanh toán</h1>
    </div>
    <div class="cart-view">
        <div class="grid-title">
            <h3>
                Sản phẩm đã đặt mua</h3>
        </div>
        <div class="bought-block">
            <ul>
                @if (cart != null)
                {
                    foreach (var item in lstCart)
                    {
                    <li>
                        <div class="bought-item">
                            <a href="@Url.Action("Details", "product", new { id = @item.Product.ID, link = item.Product.Link })">
                                <img src="@Url.Content("~/Media/Product/" + item.Product.Image)" alt="@item.Product.Name" />
                            </a><a href="@Url.Action("Details", "product", new { id = item.Product.ID, link = item.Product.Link })">@item.Product.Name</a>
                        </div>
                    </li>
                    }
                }
            </ul>
            <a class="btn btn-blue" id="btn-update-cart" href="@Url.Action("Index", "ShoppingCart")">
                Chỉnh sửa giỏ hàng</a>
        </div>
        <div class="grid-title">
            <h3>
                Thực hiện thanh toán</h3>
        </div>
        <div class="payment-block">
            @using (Html.BeginForm("PaymentAction", "Payment", FormMethod.Post, new { @class = "form-horizontal" }))
            {
                <div class="step-ribbon">
                    <ul class="list-step-bullet">
                        @if (SessionManagement.GetSessionReturnToString("UserID") == null)
                        {
                            <li class="active"><span>Đăng nhập</span></li>
                        }
                        <li><span>Thông tin người mua</span></li>
                        <li><span>Thông tin thanh toán</span></li>
                        <li><span>Hoàn tất thanh toán</span></li>
                    </ul>
                    <div class="clearfix">
                    </div>
                </div>
                <ul class="payment-info">
                    @if (SessionManagement.GetSessionReturnToString("UserID") == null)
                    {
                        <li class="payment-item">
                            <div class="payment-content">
                                <h3 class="notice-title">
                                    Nếu bạn chưa đăng nhập, hãy đăng nhập / Nếu chưa có tài khoản, hãy đăng ký</h3>
                                <ul class="payment-list">
                                    <li>
                                        <input id="second-btn-login" class="btn" type="button" value="Đăng nhập" />
                                        <a id="second-btn-register" class="btn orange btn-blue"  href="@Url.Action("Register", "Home")">
                                            Đăng ký</a> </li>
                                </ul>
                            </div>
                        </li>
                    }
                    <li class="payment-item">
                        <div class="payment-content">
                            <ul class="payment-list">
                                <li>
                                    @if (SessionManagement.GetSessionReturnToString("UserID") != null)
                                    {
                                        <input class="chk-chose" id="chk-use-info" type="checkbox" /><label for="chk-use-info">Sử
                                            dụng thông tin đăng ký?</label>
                                    }
                                </li>
                                <li>
                                    <label>
                                        Họ & Tên:</label><input name="name" class="txt txtname" type="text" /></li>
                                <li>
                                    <label>
                                        Địa chỉ:</label><input name="address" class="txt txtaddress" type="text" /></li>
                            </ul>
                            <ul class="payment-list">
                                <li>
                                    <label>
                                        Điện thoại:</label><input name="phone" class="txt txtphone" type="text" /></li>
                                <li>
                                    <label>
                                        Email:</label><input name="email" class="txt txtemail" type="text" /></li>
                            </ul>
                        </div>
                    </li>
                    <li class="payment-item">
                        <div class="payment-content">
                            <ul class="payment-list">
                                <li>
                                    <label>
                                        Thành tiền:
                                    </label>
                                    <span>@StringHelper.FormatVND(int.Parse(toTalPrice.ToString()))</span></li>
                                <li>
                                    <label>
                                        Giá chuyển phát:</label><span>0 VNĐ</span></li>
                                <li>
                                    <label>
                                        Số lượng:</label><span>@toTalProduct</span></li>
                            </ul>
                            <ul class="payment-list">
                                <li>
                                    <label>
                                        Tổng tiền:
                                    </label>
                                    <span>@StringHelper.FormatVND(int.Parse(toTalPrice.ToString()))</span></li>
                            </ul>
                        </div>
                    </li>
                    <li class="payment-item">
                        <div class="payment-content payment-complete">
                            <ul class="payment-list">
                                <li>
                                    <label>
                                        Khách hàng:
                                    </label>
                                    <span class="txtcustomer"></span></li>
                                <li>
                                    <label>
                                        Email:
                                    </label>
                                    <span class="txtemailcustomer"></span></li>
                                <li>
                                    <label>
                                        Điện thoại:</label><span class="txtphonenumcustomer"></span></li>
                                <li>
                                    <label>
                                        Địa chỉ giao hàng:</label><span class="txtaddresscustomer"></span></li>
                            </ul>
                            <ul class="payment-list">
                                <li>
                                    <label>
                                        Phương thức thanh toán:</label><span class="txtpaymethod"></span></li>
                                <li>
                                    <label>
                                        Tổng tiền:
                                    </label>
                                    <span>@Helper.StringHelper.FormatVND(int.Parse(toTalPrice.ToString()))</span></li>
                            </ul>
                        </div>
                    </li>
                </ul>
                <div class="payment-control">
                    <div class="items-control">
                        <a class="btn btn-blue btn-preview hidden" href="javascript:void(0)">Trở lại</a>
                        <a class="btn btn-blue btn-next" href="javascript:void(0)">Tiếp tục</a>
                        <input type="submit" class="btn orange btn-finish hidden" value="Hoàn tất" />
                    </div>
                    <div class="clearfix">
                    </div>
                </div>
            }
        </div>
    </div>
</div>
